Last active
November 13, 2024 23:53
-
-
Save lbonanomi/5a987b5f0987f3b1863245d54ae00848 to your computer and use it in GitHub Desktop.
Nag about `curl | bash`
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# The construction `curl http://example.com/shellscript.sh | bash` fills me with boiling rage | |
# | |
# export BASH_ENV=/usr/local/bin/blockCurlPipeBash.sh | |
if [[ $(grep "$(cat /proc/$$/cmdline | tr '\000' "\n" | tail -1)$" /etc/shells) ]] | |
then | |
# |- In case of non-interactive session -| |- dump PID table to find all sibling PIDs -| | |
# | |
echo $- | grep -qv i && ps awwwx -ocmd,pid,ppid | grep "$(ps -p $$ -o ppid | tail -1)$" | while read p | |
do | |
sib=$(echo "$p" | awk '{ print $(NF-1) }') | |
egrep -q ":0050|:01BB|:1F90|:20FB" /proc/$sib/net/tcp 2>/dev/null && kill -SIGSTOP $sib 2>/dev/null &&\ | |
echo "If you ๐ง๐๐๐ก๐ก๐ฎ want to execute some random-ass script from the Internet type ctrl-Z and then ๐ณ๐ด" | |
done | uniq | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment